package com.itheima.mapper;

import com.itheima.pojo.Student;
import com.itheima.pojo.StudentQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {
    @Select("SELECT COUNT(*) FROM student WHERE clazz_id = #{clazzId}")
    int countByClazzId(@Param("clazzId") Integer id);

    List<Student> list(StudentQueryParam studentQueryParam);
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("INSERT INTO student (" +
            "name, no, gender, phone, id_card, is_college, address, degree, graduation_date, clazz_id, create_time, update_time" +
            ") VALUES (" +
            "#{name}, #{no}, #{gender}, #{phone}, #{idCard}, #{isCollege}, #{address}, #{degree}, #{graduationDate}, #{clazzId}, #{createTime}, #{updateTime}" +
            ")")
    void insert(Student student);

    Student getById(Integer id);

    void updateById(Student student);

    void deleteByIds(List<Integer> ids);

    Student selectById(Integer id);

    void update(Student student);

    List<Map<String, Object>> countStudentCountData();

    List<Map> countStudentDegreeData();
}
